<?php
/************************************
*   熊店
*   @file:/server/bearshop/page/p_img.php
*   @intro:
*   @author:new_shop
*   @email:new_shop@163.com    
*   @date:Thu Feb 18 21:20:01 CST 2010
************************************/

class p_img extends page_controllor 
{
    public function __construct($get_param)
    {
        $this->__need_login = false;
        parent::__construct($get_param);
    }
    public function run()
    {
        /*
        //检测登录情况
        if(!$login)
            $this->not_found();
        //只有VIP可以查看所有图片
        elseif($this->visitor['level'] != TL_USER_LEVEL_VIP)
            $this->not_found();
        */
        
        //基本输入
        $product_sn = $this->get_input(0);
        
        $pid = $this->get_input(1);
        if(!is_product_sn($product_sn))
            $this->not_found();
        
        //取产品信息
        $oProduct = K::load_mod('product');
        $oProduct->get_by_sn($product_sn) or $this->busy();
        $aProduct = $oProduct->get_data();
        
        if(!isset($aProduct['photo_list'][$pid]))
            $this->not_found();
        
        $photoPath = pid2path($aProduct['id'] , $pid);
        if(!is_file($photoPath))
            $this->not_found();
        
//        header("Content-Type: ".$info['mime']);
        header("Content-Length: " . filesize($photoPath));
        
        $fp = fopen($photoPath , 'rb');
            
        fpassthru($fp);
        exit;
    }
}
?>